﻿using System.Collections.Generic;
using PurchaseSales.Manage.Model.Entities;
using PurchaseSales.Manage.Services;

namespace PurchaseSales.Manage.Repositories
{
    public class AuthRoleFunctionRepository : Repository<AuthRoleFunction>, IAuthRoleFunctionRepository
    {
        public AuthRoleFunction GetRoleFunction(string key, AuthRoles authRoles)
        {
            var authRoleFunction = Session.QueryOver<AuthRoleFunction>().Where(x => x.FunctionKey == key ).And(x=>x.AuthRole==authRoles).SingleOrDefault();
            return authRoleFunction;
        }

        public IList<AuthRoleFunction> GetRoleFunctionByRoleId(AuthRoles authRoles)
        {
            return Session.QueryOver<AuthRoleFunction>().Where(x => x.AuthRole == authRoles).List();
        }
    }
}